#pragma once
#include "GameEngine.h"
#include <cmath>
#include <time.h>
#include "Scene.h"



class DebugState : public GameState
{
public:

	void Init(GameEngine* game)
	{
		printf("=======Debugstate\n");


		sScene = new Scene(&(game->_Window));

		Player * Play = new Player(sf::Vector2f(100,300));
		Block * Blck = new Block(sf::Vector2f(0,600),sf::Vector2f(100000,10));
		//Blck->SetRotation(45);
		Block * Blck1 = new Block(sf::Vector2f(300.0f,310.0f),sf::Vector2f(10,100),sf::Color::Red,true);
		Blck1->SetRotation(45);
		sScene->SetFollow(Play);


		sScene->AddEntity(Play);
		sScene->AddEntity(Blck);
		sScene->AddEntity(Blck1);
	}



	void Cleanup()
	{

		printf("=======Debugstate End\n");
	}

	void Pause()
	{

	}
	void Resume()
	{

	}

	void HandleEvents(GameEngine* game)
	{
		sf::Event event;
		game->_Window.PollEvent(event);
		if (event.Type == sf::Event::Closed)
		{
			game->Quit();
		}
		if ((event.Type == sf::Event::KeyPressed) && (event.Key.Code == sf::Keyboard::Escape))
		{
			game->Quit();
		}
		if (event.Type == sf::Event::Resized)
		{
			game->_Width = event.Size.Width;
			game->_Height = event.Size.Height;
			game->_Window.SetView(sf::View(sf::FloatRect(0,0,(float)event.Size.Width,(float)event.Size.Height)));
		}
		game->_Time.Reset();
	}




	void Update(GameEngine* game)
	{
		sScene->Update();
	}

	void Draw(GameEngine* game)
	{
		game->_Window.Clear(sf::Color(40,40,40));

		sScene->Render();

		game->_Window.Display();
	}

	static DebugState* Instance()
	{
		return &iDebugstate;
	}
protected:
	DebugState(){};
private:

	static DebugState iDebugstate;


	Scene * sScene;
};

DebugState DebugState::iDebugstate;